/*******************************************************************************
 * Copyright (c) 2010 Mikhail Garber.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License (LGPL)
 * which accompanies this distribution
 * 
 * Contributors:
 *     Mikhail Garber - initial API and implementation
 ******************************************************************************/
package plumber.component;

import java.lang.reflect.Method;

import plumber.common.Utils;


/**
 * a Component Manager that can find components on the classpath
 * @author mgarber
 *
 */
public class ClasspathComponentManager extends AbstractComponentManager {

	
	@Override
	public Object find(String componentName, String methodName) {
		Class<?> clazz;
		try {
			clazz = Class.forName(componentName);
			Object o = clazz.newInstance();
			Method m = findMethod(methodName, clazz);
			Utils.validatePresent(m, methodName);
			return o;
		} catch (Exception e) {
			throw new RuntimeException(e);
		}
		
		
	}

}
